package com.examination.system.administrator.controller;



import com.examination.api.administrator.AttendanceControllerApi;
import com.examination.api.administrator.ParentControllerApl;
import com.examination.framework.model.response.CommonCode;
import com.examination.framework.model.response.QueryResponseResult;
import com.examination.system.administration.Attendance;
import com.examination.system.administration.ext.QueryAttendance;
import com.examination.system.administration.response.AddAdministrationResult;
import com.examination.system.administrator.service.AttendanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.Callable;

/**
 * @author 寇淇芮
 * @Date 2019/10/10 11:02
 */
@RestController
@RequestMapping("/administrator/attendance")
public  class AttendanceController implements AttendanceControllerApi, ParentControllerApl<Attendance> {

    @Autowired
    private AttendanceService attendanceService;

    @Override
    @PostMapping("/queryAttendance")
    public Callable<QueryResponseResult> findQueryAttendance(@RequestBody(required = false) QueryAttendance queryAttendance){
        //1.8之前
       /* Callable<QueryResponseResult> callable = new Callable<QueryResponseResult>() {
            @Override
            public QueryResponseResult call() throws Exception {
               return attendanceService.findQueryAttendance(queryAttendance);
            }
        };
        return callable;*/
        //1.8后
        return  ()->{return attendanceService.findQueryAttendance(queryAttendance);};
    }




    @PostMapping("/add")
    public Callable<QueryResponseResult> addAdministrationResult(){
        return ()->{return  attendanceService.findDataAll();};
    }

    @Override
    public AddAdministrationResult addData(Attendance attendance) {
        return null;
    }
}
